var ThumbnailsBox = new Lang.Class({
Name: 'ThumbnailsBox',
+ Extends: St.Widget,
_init() {
- this.actor = new Shell.GenericContainer({ reactive: true,
- style_class: 'workspace-thumbnails',
- request_mode: Clutter.RequestMode.WIDTH_FOR_HEIGHT });
- this.actor.connect('get-preferred-width', this._getPreferredWidth.bind(this));
- this.actor.connect('get-preferred-height', this._getPreferredHeight.bind(this));
- this.actor.connect('allocate', this._allocate.bind(this));
+ this.parent({ reactive: true,
+ style_class: 'workspace-thumbnails',
+ request_mode: Clutter.RequestMode.WIDTH_FOR_HEIGHT });
+
+ this.actor = this;
this.actor._delegate = this;
let indicator = new St.Bin({ style_class: 'workspace-thumbnail-indicator' });
Shell.util_set_hidden_from_pick(indicator, true);
this._indicator = indicator;
- this.actor.add_actor(indicator);
+ this.add_actor(indicator);
this._dropWorkspace = -1;
this._dropPlaceholderPos = -1;
this._dropPlaceholder = new St.Bin({ style_class: 'placeholder' });
- this.actor.add_actor(this._dropPlaceholder);
+ this.add_actor(this._dropPlaceholder);
this._spliceIndex = -1;
this._targetScale = 0;
this._thumbnails = [];
- this.actor.connect('button-press-event', () => Clutter.EVENT_STOP);
- this.actor.connect('button-release-event', this._onButtonRelease.bind(this));
- this.actor.connect('touch-event', this._onTouchEvent.bind(this));
+ this.connect('button-press-event', () => Clutter.EVENT_STOP);
+ this.connect('button-release-event', this._onButtonRelease.bind(this));
+ this.connect('touch-event', this._onTouchEvent.bind(this));
Main.overview.connect('showing',
this._createThumbnails.bind(this));
_updateSwitcherVisibility() {
let workspaceManager = global.workspace_manager;
- this.actor.visible =
+ this.visible =
this._settings.get_boolean('dynamic-workspaces') ||
workspaceManager.n_workspaces > 1;
},
_activateThumbnailAtPoint(stageX, stageY, time) {
- let [r, x, y] = this.actor.transform_stage_point(stageX, stageY);
+ let [r, x, y] = this.transform_stage_point(stageX, stageY);
for (let i = 0; i < this._thumbnails.length; i++) {
let thumbnail = this._thumbnails[i]
},
_onDragMotion(dragEvent) {
- if (!this.actor.contains(dragEvent.targetActor))
+ if (!this.contains(dragEvent.targetActor))
this._onLeave();
return DND.DragMotionResult.CONTINUE;
},
return;
this._dropPlaceholderPos = -1;
- this.actor.queue_relayout();
+ this.queue_relayout();
},
// Draggable target interface
return DND.DragMotionResult.CONTINUE;
let canCreateWorkspaces = Meta.prefs_get_dynamic_workspaces();
- let spacing = this.actor.get_theme_node().get_length('spacing');
+ let spacing = this.get_theme_node().get_length('spacing');
this._dropWorkspace = -1;
let placeholderPos = -1;
if (this._dropPlaceholderPos != placeholderPos) {
this._dropPlaceholderPos = placeholderPos;
- this.actor.queue_relayout();
+ this.queue_relayout();
}
if (this._dropWorkspace != -1)
thumbnail.setPorthole(this._porthole.x, this._porthole.y,
this._porthole.width, this._porthole.height);
this._thumbnails.push(thumbnail);
- this.actor.add_actor(thumbnail.actor);
+ this.add_actor(thumbnail.actor);
if (start > 0 && this._spliceIndex == -1) {
// not the initial fill, and not splicing via DND
set scale(scale) {
this._scale = scale;
- this.actor.queue_relayout();
+ this.queue_relayout();
},
get scale() {
set indicatorY(indicatorY) {
this._indicatorY = indicatorY;
- this.actor.queue_relayout();
+ this.queue_relayout();
},
get indicatorY() {
// Once that's complete, we can start scaling to the new size and collapse any removed thumbnails
this._iterateStateThumbnails(ThumbnailState.ANIMATED_OUT, thumbnail => {
- this.actor.set_skip_paint(thumbnail.actor, true);
this._setThumbnailState(thumbnail, ThumbnailState.COLLAPSING);
Tweener.addTween(thumbnail,
{ collapseFraction: 1,
this._stateUpdateQueued = true;
},
- _getPreferredHeight(actor, forWidth, alloc) {
+ vfunc_get_preferred_height(forWidth) {
// Note that for getPreferredWidth/Height we cheat a bit and skip propagating
// the size request to our children because we know how big they are and know
// that the actors aren't depending on the virtual functions being called.
- if (!this._ensurePorthole()) {
- alloc.min_size = -1;
- alloc.natural_size = -1;
- return;
- }
+ if (!this._ensurePorthole())
+ return [0, 0];
let workspaceManager = global.workspace_manager;
- let themeNode = this.actor.get_theme_node();
+ let themeNode = this.get_theme_node();
+
+ forWidth = themeNode.adjust_for_width(forWidth);
let spacing = themeNode.get_length('spacing');
let nWorkspaces = workspaceManager.n_workspaces;
let totalSpacing = (nWorkspaces - 1) * spacing;
- alloc.min_size = totalSpacing;
- alloc.natural_size = totalSpacing + nWorkspaces * this._porthole.height * MAX_THUMBNAIL_SCALE;
+ let naturalHeight = totalSpacing + nWorkspaces * this._porthole.height * MAX_THUMBNAIL_SCALE;
+
+ return themeNode.adjust_preferred_height(totalSpacing, naturalHeight);
},
- _getPreferredWidth(actor, forHeight, alloc) {
- if (!this._ensurePorthole()) {
- alloc.min_size = -1;
- alloc.natural_size = -1;
- return;
- }
+ vfunc_get_preferred_width(forHeight) {
+ if (!this._ensurePorthole())
+ return [0, 0];
let workspaceManager = global.workspace_manager;
- let themeNode = this.actor.get_theme_node();
+ let themeNode = this.get_theme_node();
+
+ forHeight = themeNode.adjust_for_height(forHeight);
- let spacing = this.actor.get_theme_node().get_length('spacing');
+ let spacing = themeNode.get_length('spacing');
let nWorkspaces = workspaceManager.n_workspaces;
let totalSpacing = (nWorkspaces - 1) * spacing;
scale = Math.min(scale, MAX_THUMBNAIL_SCALE);
let width = Math.round(this._porthole.width * scale);
- alloc.min_size = width;
- alloc.natural_size = width;
+
+ return themeNode.adjust_preferred_width(width, width);
},
// The "porthole" is the portion of the screen that we show in the
return true;
},
- _allocate(actor, box, flags) {
+ vfunc_allocate(box, flags) {
+ this.set_allocation(box, flags);
+
let rtl = (Clutter.get_default_text_direction () == Clutter.TextDirection.RTL);
if (this._thumbnails.length == 0) // not visible
return;
let workspaceManager = global.workspace_manager;
- let themeNode = this.actor.get_theme_node();
+ let themeNode = this.get_theme_node();
+
+ box = themeNode.get_content_box(box);
let portholeWidth = this._porthole.width;
let portholeHeight = this._porthole.height;